package com.ease.context.designpattern;

/**
 * Double-checked locking and the Singleton pattern <url>http://www.ibm.com/developerworks
 * /java/library/j-dcl.html?dwzone=java</url> <url>http://www.ibm.com/developerworks/java/library/j-dcl/index.html</url>
 * 
 * @author nathanleewei
 */
public class DoubleCheckedLockingSingleton {

	private static DoubleCheckedLockingSingleton instance;

	private DoubleCheckedLockingSingleton() {
	}

	public static DoubleCheckedLockingSingleton getInstance() {
		if (null == instance) {
			synchronized (DoubleCheckedLockingSingleton.class) {
				DoubleCheckedLockingSingleton inst = instance;
				if (null == inst) {
					synchronized (DoubleCheckedLockingSingleton.class) {
						instance = new DoubleCheckedLockingSingleton();
					}
				}
			}
		}
		return instance;
	}
}
